<template>
  <div>
    <h1>gege</h1>
    {{ count }}
    <button @click="add">累加</button>
    <button @click="byebye">拜拜</button>
  </div>
</template>

<script>
import PubSub from "pubsub-js";
export default {
  name: "Gege",
  data() {
    return {
      count: 0,
    };
  },
  methods: {
    add() {
      this.count++;

      // 发布
      PubSub.publish("count", this.count);
    },
    byebye() {
      // 取消订阅
      PubSub.unsubscribe('count');
    },
  },
};
</script>

<style>
</style>